package com.gmail.bloim.serg.math;

/**
 * User: Администратор
 * Date: 26.04.13
 * Time: 7:27
 */
class Math {
    public static long combinations(int n, int r, boolean repeat) {
        if (r > n - r) {
            return factorial(r + 1, n) / factorial(n - r);
        } else {
            return factorial(n - r + 1, n) / factorial(r);
        }
    }

    private static long factorial(int n) {
        return factorial(2,n);
    }

    private static long factorial(int start, int n) {
        long res = 1;
        for (int i = start; i <= n; i++) {
            res *= i;
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(combinations(5, 2, false));
        System.out.println(combinations(200, 2, false));
    }
}
